package com.wc.算法提高课.B第二章_搜索.DFS之搜索顺序.马走日;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/9/26 22:17
 * @description https://www.acwing.com/problem/content/1118/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10;
    static boolean[][] st = new boolean[N][N];
    static int[] dx = {-1, 1, -2, 2, -2, 2, -1, 1}, dy = {-2, -2, -1, -1, 1, 1, 2, 2};
    static int n, m;
    static int res;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            res = 0;
            n = sc.nextInt();
            m = sc.nextInt();
            int x = sc.nextInt(), y = sc.nextInt();
            dfs(x, y, 1);
            out.println(res);
        }
        out.flush();
    }

    static void dfs(int x, int y, int cnt) {
        if (cnt == n * m) {
            res++;
            return;
        }
        st[x][y] = true;
        for (int i = 0; i < 8; i++) {
            int a = x + dx[i], b = y + dy[i];
            if (a < 0 || a >= n || b < 0 || b >= m) continue;
            if (st[a][b]) continue;
            dfs(a, b, cnt + 1);
        }
        st[x][y] = false;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
